package top.lshaci.learning.alibaba.cloud.sentinel.hello.service;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

/**
 * CustomService
 *
 * @author lshaci
 * @since 1.0.0
 */
@Service
public class CustomService {

    public void custom() {
        try (Entry entry = SphU.entry("resourceName")) {
            // 被保护的业务逻辑
            // TODO
        } catch (BlockException e) {
            // 资源访问阻止，被限流或被降级
            // TODO 进行相应的处理操作
        }
    }
}
